home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / xpat2-1.000 / xpat2-1 / xpat2-1.04 / src / X-sound_SUN.c < prev    next >
C/C++ Source or Header  |  1994-09-27  |  1KB  |  40 lines

  1. /*****************************************************************************/
  2. /*                                         */
  3. /*                                         */
  4. /*    X patience version 2 -- module sound-SUN.c                 */
  5. /*                                         */
  6. /*    written by Michael Bischoff                         */
  7. /*    see COPYRIGHT.xpat2 for Copyright details                 */
  8. /*                                         */
  9. /*                                         */
  10. /*****************************************************************************/
  11. #include "X-pat.h"
  12.  
  13. #ifndef AUDIO_DEVICE
  14. #define AUDIO_DEVICE "/dev/audio"
  15. #endif
  16.  
  17. void play_sound(const char *filename) {
  18.     static int audio = 1;
  19.     if (audio && checksound()) {
  20.     char fullname[200];
  21.     FILE *fp, *fsnd;
  22.     int c;
  23.     if (!(fsnd = fopen(AUDIO_DEVICE, "wb"))) {
  24.         audio = 0;
  25.         return;        /* cannot open /dev/audio */
  26.     }
  27.     XSync(dpy, 0);    /* text first! */
  28.     sprintf(fullname, "%s/audio/%s.au", LIBDIR, filename);
  29.     if (!(fp = fopen(fullname, "rb"))) {
  30.         fclose(fsnd);
  31.         return;
  32.     }
  33.     /* yeah, copy data */
  34.     while ((c = getc(fp)) != EOF)
  35.         fputc(c, fsnd);
  36.     fclose(fsnd);
  37.     fclose(fp);
  38.     }
  39. }
  40.